$sum = AtomicAdd
(<DeviceId>, "<$Variable>", <Value>)
Increments/decrements
the value of a variable in a particular device.
Parameters
<DeviceId>
The
device where the variable is declared.
<$Variable>
The
variable whose value is to be modified.
<Value>
The
value to be incremented/decremented.
Return Value
Returns an integer value.
Remarks
- The function performs only integer addition/subtraction.
- While executing this statement, the system would
perform a Lock on the variable to prevent any
external manipulation
on its value.
Example
$ret = AtomicAdd(1, "$Count", 5)
- if prior to addition $Count = 5, then after this both $Count and $ret will contain 10.
$ret = AtomicAdd(1, "$Count", -1)
- if $Count = 5, then after this operation, both $Count and $ret will contain 4.